package com.young.logistics.controller;

import com.young.logistics.dto.Order;
import com.young.logistics.entity.Logistics;
import com.young.logistics.mapper.LogisticsMapper;
import io.seata.spring.annotation.GlobalTransactional;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.UUID;

    @RequestMapping("logistics")
@RestController
public class LogisticsController {

    @Autowired
    private LogisticsMapper logisticsMapper;

    @RequestMapping("create")
    public void insert(@RequestBody Logistics logistics){
        logisticsMapper.insert(logistics);
    }

    @RequestMapping("create/by/order")
    public void insert(@RequestBody Order Order){
        Logistics logistics = new Logistics();
        logistics.setTradeNo(Order.getTradeNo());
        logistics.setLogisticsNo(UUID.randomUUID().toString());
        int a = 1/0;
        logisticsMapper.insert(logistics);
    }
}
